package cn.tedu.property.management.controller;

import cn.tedu.property.management.pojo.dto.MaintenanceBusinessAddNewDTO;
import cn.tedu.property.management.pojo.dto.OrderUpdateDTO;
import cn.tedu.property.management.pojo.dto.RepairAddNewDTO;
import cn.tedu.property.management.pojo.dto.RepairUpdateDTO;
import cn.tedu.property.management.pojo.vo.OrderListItemVO;
import cn.tedu.property.management.pojo.vo.OrderStandardVO;
import cn.tedu.property.management.pojo.vo.RepairListItemVO;
import cn.tedu.property.management.pojo.vo.RepairStandardVO;
import cn.tedu.property.management.service.IMaintenanceService;
import cn.tedu.property.management.service.IRepairerService;
import cn.tedu.property.management.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 处理维修业务的控制层
 */
@Slf4j
@RestController
@RequestMapping("/repair")
@Api(tags = "维修人员管理模块")
public class RepairController {

    @Autowired
    private IRepairerService repairerService;


    @PostMapping("/add-new")
    @ApiOperation("添加维修人员")
    @ApiOperationSupport(order = 100)
    public JsonResult insert(RepairAddNewDTO repairAddNewDTO){
        log.info("开始处理添加维修人员的请求,");
        repairerService.addNew(repairAddNewDTO);
        return JsonResult.ok();
    }

    @PostMapping("/delete/{id}")
    @ApiOperation("根据id删除维修人员")
    @ApiImplicitParam(value = "id",name = "id",example = "1")
    @ApiOperationSupport(order = 200)
    public JsonResult deleteById(@PathVariable Long id){
        log.info("开始处理删除维修人员的请求,");
        repairerService.deleteById(id);
        return JsonResult.ok();
    }

    @PostMapping("/update")
    @ApiOperation("修改维修人员")
    @ApiOperationSupport(order = 300)
    public JsonResult update(Long id, RepairUpdateDTO repairUpdateDTO){
        log.info("开始处理修改维修人员的请求,");
        repairerService.update(id,repairUpdateDTO);
        return JsonResult.ok();
    }

    @PostMapping("/select/all")
    @ApiOperation("查询所有维修人员")
    @ApiOperationSupport(order = 400)
    public JsonResult<List<RepairListItemVO>> getAll(){
        log.info("开始处理查询所有维修人员的请求,");
        List<RepairListItemVO> repairs = repairerService.getAllRepairs();
        return JsonResult.ok(repairs);
    }



























}
